package de.karlNet.login.attributeMapper;

import java.util.List;

import javax.naming.NamingException;
import javax.naming.directory.Attributes;

import org.springframework.stereotype.Component;

import de.karlNet.sambamanager.ldapModel.LdapGroup;
import de.karlNet.sambamanager.ldapModel.LdapObject;

@Component
public class GroupExtractor extends LdapObjectExtractor {

	@Override
	public LdapObject extract(Attributes attributes, List<String> objectClasses)
			throws NamingException {
		if (objectClasses.contains("group")) {
			String dn = this.tryToGetString("distinguishedname", attributes,
					tryToGetString("dn", attributes));
			String cn = this.tryToGetString("name", attributes,
					tryToGetString("cn", attributes));
			return new LdapGroup(cn, dn);
		}
		return null;
	}

}
